package com.starleague.game.trait;

import java.util.ArrayList;
import java.util.List;

import com.starleague.entity.IEntityVisitor;
import com.starleague.game.AbstractGame;
import com.starleague.game.AbstractTeam;
import com.starleague.trait.AbstractTrait;
import com.starleague.trait.HasTraits;
import com.starleague.trait.TraitHelper;

public abstract class AbstractTraitTeam
        extends AbstractTeam
        implements HasTraits
{
    private final List<? extends AbstractTrait> traitList = new ArrayList<>();

    protected AbstractTraitTeam(AbstractGame game,
                                String name)
    {
        super(game, name);
    }

    protected AbstractTraitTeam()
    {
        // For serialization
    }

    @Override
    public List<? extends AbstractTrait> getTraits()
    {
        return this.traitList;
    }

    @Override
    public AbstractTrait getTraitById(String traitId)
    {
        return TraitHelper.findTraitByTraitId(this.traitList, traitId);
    }

    @Override
    public void accept(IEntityVisitor visitor)
    {
        super.accept(visitor);
        visitor.visit(TRAITS, this.traitList);
    }
}
